﻿/// <reference path="../Extension.js" />
/// <reference path="../Default.js" />

$(document).ready(function () {
    $('.Accordion').accordion({
        autoHeight: false,
        navigation: true,
        collapsible: true,
        active: 0
    });

    $("#tDias").jqGrid({
        datatype: 'json',
        url: '/CondicoesPagamento/DiasCondicaoList',
        mtype: 'GET',
        colNames: ['', 'Id', 'Dias', ],
        colModel: [
            { name: "actions", formatter: "actions", editable: false, sortable: false, resizable: false, fixed: true, align: 'center', width: 26, "formatoptions": { keys: false, editbutton: false, delbutton: true} },
            { name: 'ID_DICP', index: 'ID_DICP', width: 80, editable: true, align: 'right', search: false, hidden: true },
            { name: 'DIA_DICP', index: 'DIA_DICP', width: 80, editable:true, align: 'right', searchoptions: { sopt: ['eq']} }
        ],
        gridComplete: function () { loadInputs(); },
        pager: '#pDias',
        pgbuttons: false,
        pginput: false,
        viewrecords:false,
        height: 'auto',
        rowNum: 20,
        sortname: 'DIA_DICP',
        sortorder: "asc",
        viewrecords: false,
        editurl: '/CondicoesPagamento/DiaDelete',
        postData: {
            COD_CDPG: function () { return $('#COD_CDPG').val(); }
        },
        ondblClickRow: function (id) {
            editRow('tDias', '/CondicoesPagamento/DiaUpdate', id, { COD_CDPG: $('#COD_CDPG').val() });
        }
    }).navGrid("#pDias", {
        edit: false, add: false, del: false, search: false, refresh: true
    }).navButtonAdd("#pDias", {
        caption: '',
        buttonicon: 'ui-icon-circle-plus',
        onClickButton: function () {
            $("#tDias").addRowData(0, {
                ID_DICP: '', DIA_DICP: ''
            }, 'first');
            addRow('tDias', '/CondicoesPagamento/DiaUpdate', { COD_CDPG: $('#COD_CDPG').val() });
        },
        title: "adicionar dia",
        position: "last"
    });
});